{include file="public/_meta"}
        <div class="layui-fluid">
            <div class="layui-row">
                <form class="layui-form">
                  <div class="layui-form-item">
                      <label for="name" class="layui-form-label">
                          <span class="x-red">*</span>分类名称
                      </label>
                      <div class="layui-input-inline" style="width: 30%">
                          <input type="text" id="name" name="cat_name" class="layui-input">
                      </div>
                  </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label"><span class="x-red">*</span>请选择分类</label>
                        <div class="layui-input-block" style="width: 30%">
                            <select name="parent_id">
                                <option value="0">顶级分类</option>
                                {volist name="data" id="v"}
                                    <option value="{$v.id}" {if condition="$v.id == $id"}selected{/if}>{:str_repeat('-', $v.level*5)}{$v.cat_name}</option>
                                {/volist}
                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">显示在导航</label>
                        <div class="layui-input-block">
                            <input type="radio" name="type" value="1" title="是">
                            <input type="radio" name="type" value="0" title="否" checked>
                        </div>
                    </div>


                  <div class="layui-form-item">
                      <label class="layui-form-label">
                      </label>
                      <button  class="layui-btn" lay-filter="add" lay-submit="">
                          增加
                      </button>
                  </div>
              </form>
            </div>
        </div>
        <script>layui.use(['form', 'layer'],
            function() {
                $ = layui.jquery;
                var form = layui.form,
                layer = layui.layer;

                //监听提交
                form.on('submit(add)', function(data) {
                    //发异步，把数据提交给php
                    let url= '{:url("add")}'
                    $.post(url, data.field, function (res) {
                        if(res.status == 0) {
                            layer.msg("新增成功", function() {
                                window.location="{:url('index')}";
                            });
                        } else {
                            layer.msg(res.message, function () {
                                
                            });
                            return false;
                        }
                    }, 'json')
                    return false;
                });

            });
        </script>
    </body>
</html>
